<template>
  <a-card :bordered="false" class="card-area">
    <a-tabs defaultActiveKey="1">
      <a-tab-pane :tab="$t('key.personalInfo')" key="1">
        <stu-info :xh.sync="xh" :checked="false"></stu-info>
      </a-tab-pane>
      <a-tab-pane tab="导师信息" key="2">
        <stu-status-view v-if="studentData.xjxx" :xjxx="studentData.xjxx" :gnds="studentData.jzgXmDetail"/>
      </a-tab-pane>
    </a-tabs>
 
    <div class="ant-pro-footer-toolbar">
      <a-button style="float: right;margin-top: 10px;" :loading="loading" @click="exportPdf" type="primary">{{
        $t(`button.exportStuCard`) }}
      </a-button>
    </div>
  </a-card>
</template>

<script>
  import stuInfo from './stuInfo'
  import stuStatusView from './stuStatusView'

  import {mapState} from 'vuex'

  export default {
    // props: ['xh'],
    components: {
      stuInfo,
      stuStatusView
    },
    data() {
      return {
        loading: false,
        post: {},
        studentData: {}
      }
    },
    watch: {
      // xh (val) {
      //   if (val) {
      //     this.$api.student.studentInfo(val).then(res => {
      //       this.studentData = res.data
      //     })
      //   }
      // }
    },
    computed: {
      ...mapState({
        user: state => state.account.user,
        TYPE0124: state => state.app['TYPE0124'] // 审核状态
      }),
      xh () {
        return this.$route.query.xh
      }
    },
    beforeCreate() {
      this.form = this.$form.createForm(this)
    },
    created() {
      this.$store.dispatch('app/setDictionary', 'TYPE0124')
      // this.$api.student.studentResume(this.user.xh)
      this.$api.overseas.studentInfo(this.xh).then(res => {
        this.studentData = res.data
      })
    },
    methods: {
      audit() {
        this.form.validateFields((err, values) => {
          if (err) {
            return
          }
          this.$api.student.supplementCheck(Object.assign({xh: this.xh}, values)).then(res => {
            this.$message.warning('操作成功')
            this.form.resetFields()
            this.$emit('showList')
          })
        })
      },
      exportPdf() {
        let fileName = this.studentData.xm + '_学生学籍卡.pdf'
        this.$downloadPdf('/student/xn/exportXjCard/' + this.xh, {}, fileName)
      }
    }
  }
</script>

<style>

</style>
